package com.kaishengit.web;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.kaishengit.pojo.Milestone;
import com.kaishengit.pojo.Project;
import com.kaishengit.service.MilestoneService;
import com.kaishengit.service.ProjectService;

@Results({@Result(name=BaseAction.SUCCESS,location="project!list.action",params={"id","${projectid}"},type="redirectAction")})
public class MilestoneAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	
	@Resource
	private ProjectService projectService;
	@Resource
	private MilestoneService milestoneService;
	
	private Milestone milestone;
	private String projectid;
	private Project project;

	@Override
	public String delete() throws Exception {
		return null;
	}

	@Override
	public String input() throws Exception {
		project = projectService.findById(Integer.parseInt(projectid));
		return INPUT;
	}

	@Override
	public String list() throws Exception {
		return null;
	}

	@Override
	public String save() throws Exception {
		milestone.setProject(projectService.findById(Integer.parseInt(projectid)));
		milestoneService.save(milestone);
		return SUCCESS;
	}
	
	//get set

	public void setMilestone(Milestone milestone) {
		this.milestone = milestone;
	}

	public Milestone getMilestone() {
		return milestone;
	}

	public void setProjectid(String projectid) {
		this.projectid = projectid;
	}

	public String getProjectid() {
		return projectid;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public Project getProject() {
		return project;
	}

}
